
class CStream : public IStream
{
	long		m_cRef;
	PBYTE		m_pbMem;
	__int64		m_ullPos;
				m_ullEnd;
	__int64		m_ullSize;
	DWORD		m_dwPageSize,
				BASE_ALLOC_SIZE;
	int			m_iNumCommittedPages;
	IUnknown   *m_pOuterUnk;

	UINT		m_uNumReservedPages;
	UINT		m_uNumReservedPages;

	void freemMem();

public:
	CStream( ULONG ulInitialSize=0, DWORD dwBaseAllocSize=4096, IUnknown *pOuterUnk=NULL );
	PBYTE GetBuf();
	BYTE GetByte( bool bAdvance=true );
	__int64 GetCurPos();
	__int64 GetEndPos();
	void SetEndPos( ULONG ulNewPos );
	void SeekToBegin();
	void SeekToEnd();
	ULONG GetSize();
	void Seek( LONG ulLoc, UINT uOrigin, ULONGLONG *pullNewLoc=NULL );
	BOOL eos();
	HRESULT Reset( ULONG uSize=0, BOOL bKeepMem=0 );
	HRESULT Write( BYTE ch );
    HRESULT Write( WCHAR ch );
    HRESULT Write( UINT u );
	HRESULT Write( ULONG l );
	HRESULT Read( PBYTE pch )
	HRESULT SetSize( ULONGLONG ullNewSize )
};

/*
TStream = class(TObject)
  private
    function GetPosition: Int64;
    procedure SetPosition(const Pos: Int64);
    procedure SetSize64(const NewSize: Int64);
  protected
    function GetSize: Int64; virtual;
    procedure SetSize(NewSize: Longint); overload; virtual;
    procedure SetSize(const NewSize: Int64); overload; virtual;
  public
    function Read(var Buffer; Count: Longint): Longint; virtual; abstract;
    function Write(const Buffer; Count: Longint): Longint; virtual; abstract;
    function Seek(Offset: Longint; Origin: Word): Longint; overload; virtual;
    function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; virtual;
    procedure ReadBuffer(var Buffer; Count: Longint);
    procedure WriteBuffer(const Buffer; Count: Longint);
    function CopyFrom(Source: TStream; Count: Int64): Int64;
    procedure WriteResourceHeader(const ResName: string; out FixupInfo: Integer);
    procedure FixupResourceHeader(FixupInfo: Integer);
    procedure ReadResHeader;
    property Position: Int64 read GetPosition write SetPosition;
    property Size: Int64 read GetSize write SetSize64;
  end;
*/